﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Strategy.Core.Generator.XML.Classes;
using System.IO;
using System.Xml.Serialization;
using Strategy.Core.Trade;

namespace Strategy.Core.Generator
{
    class Program
    {
        public static string generateInterfaceImplDelegate(Type t, string delegate_prop)
        {
            StringBuilder sb = new StringBuilder();            
            foreach(var el2 in t.GetMethods())
            {
                sb.Append("public "+el2.ReturnType.FullName+" "+el2.Name+" ( ");
                foreach(var m in el2.GetParameters())
                    sb.Append(m.ParameterType.FullName + " " + m.Name + (m == el2.GetParameters().Last() ? "  " : " , ").ToString());
                sb.Append(" ) { ");
                if (el2.ReturnType.Name != "Void")
                    sb.Append(" return ");
                sb.Append(" "+delegate_prop+"."+el2.Name+" ( ");
                foreach(var m in el2.GetParameters())
                    sb.Append( m.Name + (m == el2.GetParameters().Last() ? "  " : " , ").ToString());
                sb.AppendLine(") ; }");
                Console.WriteLine(sb.ToString());
            }
            return sb.ToString();
        }
                                            
        public static void deserialize()
        {
            try
            {
                StreamReader str = new StreamReader("test.xml");
                XmlSerializer xSerializer = new XmlSerializer(typeof(Context));
                Context myCdCatalogue = (Context)xSerializer.Deserialize(str);
                str.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            //var methods = typeof(Strategy.Core.Trade.IStrategy).GetProperties();
            StrategyGenerator sg = new StrategyGenerator();
            sg.GenerateClassesFromXML("XML/SampleStrategy.xml", "generatedproject\\", "PerfectStrategy");
         
        }
    }
}
